<?php

namespace App\Http\Requests;

use App\Models\Student;
use Illuminate\Foundation\Http\FormRequest;

class StudentAdd extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function attributes()
    {
        return [
            'student_name' => '学生姓名',
            'sex' => '性别',
            'student_class_id' => '班级',
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'student_name' => 'nullable|string',
            'sex' => 'nullable|in:'.Student::SIX_STR,
            'student_class_id' => 'nullable|integer',
        ];
    }

    public function messages()
    {
        return [
            'student_name.string' => '姓名必须是字符',
            'sex.regex' => '性别格式不对',
            'student_class_id.numeric' => '班级必须是数字'
        ];
    }
}
